#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

#define ElemType int

typedef struct NODE {
	ElemType data;
	struct NODE* next;
}Node;

typedef struct LINKLIST {
	Node* head;
	int length;
}Linklist;

void InitLinkList(Linklist* List) {
	List = (Linklist*)malloc(sizeof(Linklist));
	if (List == NULL) {
		perror("MALLOC:");
		return 0;
	}
	List->head = NULL;
	List->length = 0;
}

void Insert_Elem(Linklist* List, int i,ElemType e) {
	if (i > List->length || i < 0) {
		printf("the location of insertion is fault\n");
		return;
	}
	Node* p=(Node*)malloc(sizeof(Node));
	if (p == NULL) {
		perror("MALLOC:");
		return 0;
	}
	p->data = e;
	Node* tmp = List->head;
	for (int k = 0; k < i - 1; k++) {
		tmp = tmp->next;
	}
	p->next = tmp->next;
	tmp->next = p;
	printf("Insert successfully\n");
	List->length++;
	return;
}

void Delete(Linklist* List, int i) {
	if (i > List->length || i < 0) {
		printf("the location of insertion is fault\n");
		return;
	}
	Node* tmp = List->head;
	for (int k = 0; k < i - 1; k++) {
		tmp = tmp->next;
	}
	Node* p = tmp->next;
	tmp->next = p->next;
	free(p);
	p = NULL;
	List->length--;
}

void Destroy(Linklist* List) {
	free(List->head);
	List->head = NULL;
	free(List);
	List = NULL;
}

int main(void) {

	return 0;
}